package com.zmj.sy.mom.srv.aps.mapper;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Constants;
import com.zmj.sy.mom.srv.aps.bean.bo.ReverseGroup;
import com.zmj.sy.mom.srv.aps.bean.entity.resource.Station;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface StationMapper extends SyMapper<Station> {

    @Select(" select s.* from tb_station s " +
            " left join tb_group g on s.group_id = g.id  " +
            " ${ew.customSqlSegment}")
    List<Station> findByGroupId(@Param(Constants.WRAPPER) QueryWrapper<Station> query);

   @Update(" update tb_station set station_status = #{state} where my_code = #{unitCode}")
   public void returnToRequester(@Param("unitCode") String unitCode,@Param("state")  int state);

   @Delete(" delete from tb_station where id = #{id}")
    void deleteByIdHard(@Param("id")Integer id);

    @Select("select s.id, s.group_id, s.id AS stationId , g.name groupName, g.my_code groupCode, s.work_ability " +
            "from tb_station s  " +
            "left join tb_group g on s.group_id = g.id and g.deleted = 0 " +
            "where s.deleted = 0 and g.my_code is not null")
    List<ReverseGroup> selectAll();

}
